I am trying to create a link to open an ssh connection to another computer. I am an OS X 10.5.7 and Ubuntu 9.04 user. I am tempted to create a symbolic link as such:
ln -s "ssh user#computer_name" computer_name
I know this is wrong. Could someone point me in the right direction?
you can create an alias somewhere in the file your shell runs when it starts (i.e. .bashrc for bash):
alias computer_name="ssh user#computer_name"
Stick the command in a bash file somewhere and symbolic link to that.
There is a better way:
open .ssh/config and past this template
Host your_alias_for_remote_server
Hostname 0.0.0.0
User user_name
Compression yes
Now you can type ssh your_alias_for_remote_server and you will be immediately connected with your server
Edit ~/.profile and add the following:
computer_name(){
ssh user#computer_name
}
Log out of the Terminal and reopen the Terminal. The command "computer_name" should now work.
Related
When I'm login in to one remote machine over ssh it logs in as -bash-4.2$ in terminal but on other remote hosts user#host$. How to correct this? I accidentally executed rm -rf *.
Looks like I delete some important files from home directory.
Note: I'm not the admin.
Assuming you want all your hosts to have a prompt of the form user#host$, you need to add to your $HOME/.bashrc on each of these machines the correct value of PS1:
PS1='\u#\h$ '
Maybe you have deleted the .bashrc file
vi .bashrc
put this code
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
now su root
I am trying to use SFTP to upload the entire directory to remote host but I got a error.(I know SCP does work, but I really want to figure out the problem of SFTP.)
I used the command as below:
(echo "put -r LargeFile/"; echo quit)|sftp -vb - username#remotehost:TEST/
But I got the error "Couldn't canonicalise: No such file or directory""Unable to canonicalise path "/home/s1238262/TEST/LargeFile"
I thought it was caused by access rights. So, I opened a SFTP connection to the remote host in interactive mode and tried to create a new directory "LargeFile" in TEST/. And I succeeded. Then, I used the same command as above to uploading the entire directory "LargeFile". I also succeeded. The subdirectories in LargeFile were create or copied automatically.
So, I am confused. It seems only the LargeFile/ directory cannot be created in non-interactive mode. What's wrong with it or my command?
With SFTP you can only copy if the directory exists. So
> mkdir LargeFile
> put -r path_to_large_file/LargeFile
Same as the advice in the link from #Vidhuran but this should save you some reading.
This error could possibly occur because of the -r option. Refer https://unix.stackexchange.com/questions/7004/uploading-directories-with-sftp
A better way is through using scp.
scp -r LargeFile/"; echo quit)|sftp -vb - username#remotehost:TEST/
The easiest way for me was to zip my folder on local LargeFile.zip and simply put LargeFile.zip
zip -r LargeFile.zip LargeFile
sftp www.mywebserver.com (or ip of the webserver)
put LargeFile.zip (it will be on your remote server local directory)
unzip Largefile.zip
If you are using Ubuntu 14.04, the sftp has a bug. If you have the '/' added to the file name, you will get the Couldn't canonicalize: Failure error.
For example:
sftp> cd my_inbox/ ##will give you an error
sftp> cd my_inbox ##will NOT give you the error
Notice how the forward-slash is missing in the correct request. The forward slash appears when you use the TAB key to auto-populate the names in the path.
i was created a bash script my_vp.sh that use 2 command:
setterm -cursor off
setterm -powersave off
[...]
#execute video commands
[...]
and is in a computerA
but when i execute it by ssh by another computerB_terminal:
ssh pi#192.168.1.1
execute video commands work correctly in the computerA (the same where is the script)
but the command setterm works in the computerB (the terminal where i execute the ssh command).
somebody can help me with solucione it?
thank you very much!
I am not sure I understood the question:
to execute a local script, but on another machine:
scp /path/to/local/script.bash pi#192.168.1.1:/tmp/copy_of_script.bash
and then, if it's copied correctly, execute it:
ssh pi#192.168.1.1 "chmod +x /tmp/copy_of_script.bash"
ssh pi#192.168.1.1 "bash /tmp/copy_of_script.bash"
to have the remote video (Xwindows, etc) commands appear on the originating machine:
replace : ssh with : ssh -x (to allow X-Forwarding, which will allocate a DISPLAY automatically on the remote machine that will be tunneled back to the originating machine)
for the X-forwarding to work, there are some requirements (usually ok by default, but ymmv) : read more about those requirements in this Unix.se answer
I have a windows shared folder named \\mymachine\sf and I want to map it as a ubuntu device. I use smbmount command as below:
smbmount //mymachine/sf /mnt/sf -o <username>
The output is like
retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
I'm sure the device exists and mymachine is ping'ed through.
Any idea?
Double check that the share exists and is the name you expect with:
smbclient -L //mymachine -U <username>
Also double check that the directory your share points to (as mentioned in smb.conf) actually exists on the server/host. This is one situation where you will receive that error, despite smbclient -L //hostname giving reasonable output.
Make sure that the directory the samba share points to exists on the server side as well (might have been deleted or mount might have failed at boot). smbclient -L //mymachine -U <username> lists shares as available even though they're not available!
I'm new to unix. I need to copy file over ssh. This is what I do
me#localhost ~ $ ssh you#remotehost
Then I established ssh so I get
you#remotehost ~ $
I'd like to use scp to copy files from localhost to remotehost. Once I have ssh connection, how do I change to prompt back to me#localhost so that I can use the scp command? Is there a command for that?
Edit: The reason I need the ssh is because after I copied the file I have to execute it. Is there a way to remain in the ssh session and use scp to copy the file that I'm editing at localhost
You do not have to first create an SSH connection to use SCP. Simply use the scp command from your shell, and it will connect to the other server.
Most shells exit with exit. CtrlD may also work.
You can also:
scp /path/to/local-file you#remotehost:/remote/path
Try screen command.
You can use scp on either side. Here are two examples:
If you are on your local host:
scp myfile you#remotehost:
If you are on the remote host:
scp you#<localhost's hostname>:myfile .
Substitute your localhost's hostname for <localhost's hostname> in the second command. If you are behind a router, it will be easier to use the first one.
Both assume that myfile is in the home directory on localhost and is being sent to the home directory on remotehost.