Google Compute Engine - troubleshooting SSH default port [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
when running
gcutil ssh myproject_name
ssh run with the following command
ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/MyUser/.ssh/google_compute_engine -A -p 22 MyUser#xxx.xxx.xxx.xxx
i've changed my ssh port to 1234 in sshd_config file and opened a firewall rule at my compute engine console. executing the following command works perfect and connection is established
ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/MyUser/.ssh/google_compute_engine -A -p 1234 MyUser#xxx.xxx.xxx.xxx
but when running this command gcutil ssh myproject_name port 22 is being called.
How & where can i change the default port of ssh so I wont have to use the long command in order to connect to my instance

gcutil supports alternate ports via the --ssh_port flag. In your case, this should work:
gcutil ssh --ssh_port 1234 INSTANCE_NAME

Related

No remote commands executed when ssh runs as sudo [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
The following command gives the expected result (file is created):
sshpass -p pas ssh root#host 'touch foo'
But the following one does nothing on the remote host:
sudo sshpass -p pas ssh root#host 'touch foo'
The only difference here is just sudo mode.
What is the reason here? And how this can be solved?
The problem is more visible when running ssh -v.
With sudo communication interrupts after detecting the server host key.
To solve the problem ssh needs to run with the following argument -o "StrictHostKeyChecking no".

Auto accept "Configuring iptables-persistent" [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
i'm created bash script where i need to configure network, but in one of stage he ask me to save new rule, how to prevent it and set "Yes" automatically.
sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 1443
sudo apt-get -y install iptables-persistent
sudo service netfilter-persistent save
message where he ask to save
For non-terminal programs
Actually, you can always automatize input of eny word with several methods:
yes word | command
(in this word will be entered as an input of command)
or using expect, if you need more sophisticated dialog.
For terminal programs (your case)
For interactive sessions you can try it this way:
start it in a tmux session
send "Enter" using tmux send-keys
That is exactly what you want.
tmux send-keys Enter
Everything combined:
sudo tmux -L dialog-session new-session -d service netfilter-persistent save
sudo tmux -L dialog-session send-keys Enter
(actually you don't need sudo here, but I use sudo because of your sudo)

How to set up an SSH Server on OS X [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm planning on making a Bash script that sets up an SSH server. The script is only meant to work on a computer running OS X. With the research I have conducted it seems like you have to use the GUI to enable SSH. Is their a way to enable SSH through Terminal and then create a script that does so?
You can enable it from the command line (or a shell script) with:
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
You might also want to regulate access to the ssh service with the com.apple.access_ssh group:
sudo dseditgroup -o edit -a usernametoallow -t user com.apple.access_ssh
sudo dseditgroup -o edit -a otherusernametoallow -t user com.apple.access_ssh
sudo dseditgroup -o edit -a groupnametoallow -t group com.apple.access_ssh
...after which only usernametoallow, otherusernametoallow, and members of groupnametoallow will be able to ssh into the Mac.

How do I check if a port is open between two Linux servers? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
How do you check if a port is open when you cannot use telnet or install Cacti? I want to see if a port is open between two Linux servers. Telnet isn't installed. I tried this command:
cat < /dev/tcp/x.x.x.x/6061
where x.x.x.x was the remote IP address of the Linux server and port 6061 is the port that I want to test. But based on tests of known working and not working ports, this command wasn't conclusive to me. There may be an environmental explanation for that.
Install nmap and than:
nmap x.x.x.x
Better use (if installed) : netcat :
nc -zw3 <host> <port>
If you want to use the bash feature net redirection :
cat < /dev/tcp/x.x.x.x/6061
do it the right way :
{ exec 3<> /dev/tcp/127.0.0.1/6061; } &>/dev/null &&
echo "Connection to socket OK" ||
echo >&2 "Can't connect"
If it doesn't work, you need to compile bash with --enable-net-redirections

kill remote process by ssh [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I can't directly access target host, need ssh as a proxy.
How can I kill a process from local use ssh ? I try this:
ssh root#$center "ssh root#$ip \"ps -ef|grep -v grep|grep $target_dir/$main|awk '{print \$2}'|xargs kill\""
it got error:
kill: can't find process "root"
And how to avoid error where process not exist ?
Suppose your process' name is name, then you can try something like this:
ssh hostname "pid=\$(ps aux | grep 'name' | awk '{print \$2}' | head -1); echo \$pid |xargs kill"
Use pkill -f to easily kill a process by matching its command-line.
ssh root#$center ssh root#$ip pkill -f "$target_dir/$main"

Resources